<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallView.aspx.cs" Inherits="OrderView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Job Order</title>
    <link href="/Style/StyleSheet.css" rel="stylesheet" type="text/css" />
    <style>
.dxbButton {   	font-size: 11px; }
.txtLabel {font-weight:bold;font-size:11px;}
.txtValue {font-size:11px;}
hr {margin:8px;}
</style>
</head>
<body onload="javascript:LoadMap();">
    <form id="form1" runat="server">

    <script type="text/javascript">
        function ShowEdit() {
           // window.open("../Edit/Job.aspx?OrderNo=" + txt_Sn.GetText(), "name1", "width=1020,height=600,toolbar=no,scrollbars=no,menubar=no");
        }
        var clientId = null;
        var clientName = null;
        var clientAdr = null;
        var clientContact = null;
        function PutValue(s, name) {
            if (clientId != null) {
                clientId.SetText(s);
                if (clientName != null) {
                    clientName.SetText(name);
                }
                popubCtr.Hide();
                popubCtr.SetContentUrl('about:blank');
            }
        }
        function PutValue(s, name,address,contact, lat, lon) {
            if (clientId != null) {
                clientId.SetText(s);
                if (clientName != null) {
                    clientName.SetText(name);
                }
                if (clientAdr != null)
                    clientAdr.SetText(address);
                if (clientContact != null)
                    clientContact.SetText(contact);
                popubCtr.Hide();
                popubCtr.SetContentUrl('about:blank');
		document.getElementById("mapframe").contentWindow.SetMap(lat,lon,14);

            }
}

function LoadMap() {
    var la = document.getElementById("lati").innerHTML;
    var lo = document.getElementById("longi").innerHTML;
    if(la != "")
        document.getElementById("mapframe").contentWindow.SetMap(la,lo, 14);
}

        function PopupCust(txtId, txtName,txtAdr,txtContact) {
            clientId = txtId;
            clientName = txtName;
            clientAdr = txtAdr;
            clientContact = txtContact;
            popubCtr.SetContentUrl('/Modules/SelectPage/CustomerPick.aspx');
            popubCtr.SetHeaderText('Customer');
            popubCtr.Show();
        }

      

             var grid = null;
        function AddBill(gridId) {
            grid = gridId;
            popubCtr1.SetHeaderText('Invoice');
            popubCtr1.SetContentUrl('/Modules/Account/EditPage/InvoiceEdit.aspx?InvN=0&sn=' + txt_OrderNo.GetText());
            popubCtr1.Show();
        }
        function ShowBill(gridId, no) {
            grid = gridId;
            popubCtr1.SetHeaderText('Invoice');
            popubCtr1.SetContentUrl('/Modules/Account/EditPage/InvoiceEdit.aspx?InvN=' + no + '&sn=' + txt_OrderNo.GetText());
            popubCtr1.Show();
        }
        function PrintEstimate() {
            window.open("/Reports/printview.aspx?doc=51&no=" + txt_OrderNo.GetText());
        }

        function OnCallback(v) {
            alert(v);
        }
        ////////////////for dropdown list
        function RowClickHandler(s, e) {
            SetLookupKeyValue(e.visibleIndex);
            de_Cust.HideDropDown();
        }
        function SetLookupKeyValue(rowIndex) {
            de_Cust.SetText(gridPopCont.cpKeyValues[rowIndex]);
            txt_CustName.SetText(gridPopCont.cpName[rowIndex]);
            txtAddress.SetText(gridPopCont.cpAddress[rowIndex]);
            txt_CustContact.SetText(gridPopCont.cpContact[rowIndex]);
        }

        /////////////////////////////////////////////////////////////////////////////////////////////////
  </script>

    <div>
         <asp:SqlDataSource ID="dsPickSource" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1003 order by ddItemSort"  />
         <asp:SqlDataSource ID="dsPickServiceType" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1009 order by ddItemSort"  />
         <asp:SqlDataSource ID="dsPickOrderStatus" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1010 order by ddItemSort"  />
         <asp:SqlDataSource ID="dsPickTech" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select displayname as Code from [user] where role='Technician' order by name"  />
         <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="Server=.\Sqlexpress;DataBase=colorworksDB;UID=sa;PWD=1234;"
         SelectCommand="select ddItemCode as Code, ddItemId as Id from ddItems where ddItemStatus='Active' and ddGroupId=1003 order by ddItemSort"  />


         <wilson:DataSource ID="dsCust" runat="server" ObjectSpace="Touchmax.Manager.ORManager"
                TypeName="Touchmax.BoClient" KeyMember="CustId" FilterExpression="1=1" />
        <wilson:DataSource ID="dsCall" runat="server" ObjectSpace="Touchmax.Manager.ORManager"
            TypeName="Touchmax.OpActivity" KeyMember="ActivityID" FilterExpression="1=0" />
        <dxwgv:ASPxGridView ID="grid_Order" ClientInstanceName="grid_Order" runat="server"
            DataSourceID="dsCall" Width="440" KeyFieldName="ActivityID" AutoGenerateColumns="False"
            OnInit="grid_Order_Init" OnInitNewRow="grid_Order_InitNewRow">
            <SettingsPager Mode="ShowAllRecords">
            </SettingsPager>
            <SettingsEditing Mode="EditForm" />
            <SettingsCustomizationWindow Enabled="True" />
            <Settings ShowColumnHeaders="false" />
            <Templates>
                <EditForm>
                    <table border="0" width="440">
                        <tr>
                            <td Width="90" class="txtLabel">Client</td>
                            <td width="160" class="txtValue">
                                <%# Eval("CustName") %>
                                
                                        <div style="display:none">
                                        <div id="lati"><%# Eval("Latitude") %></div>
                                        <div id="longi"><%# Eval("Longitude") %></div>
                                        </div>
                            </td>
                            <td rowspan="7">
                            <div style="padding-left:0px;border:solid 2px gray;width:180px;height:180px;">
                            <iframe id="mapframe" frameborder=0 border=0 width=180 height=180 src="/framework/mapsmall.html"></iframe>
                            </div>
                            </td>
                        </tr>
                        <tr>
                            <td  class="txtLabel">
                                Call Log No
                            </td>
                            <td  class="txtValue">
                                <%# Eval("ActivityID") %>
                           
                            </td>

                        </tr>
                        <tr>
                            <td>
                                Call Date
                            </td>
                            <td>
                               <%# Eval("CallTime", "{0:MMM dd, yyyy}") %>
                            </td>
                            </tr>
                        <tr>
                            <td>
                                New Customer ?
                            </td>
                            <td>
                                <%# Eval("NewClient") %>
                            </td>
                            </tr>
                        <tr>
                            <td>
                                Answered By
                            </td>
                            <td>
                               <%# GetEmployeeCode(Eval("EmployeeID")) %>
                            </td>
                            </tr>
                            <tr>
                            <td>
                                Marketing Source
                            </td>
                            <td>
                                <%# GetItemCode(Eval("CallSourceID")) %>
                            </td>
                            </tr>
                            <tr>
                         <td>
                                Call Log Status
                            </td>
                            <td>
                                <%# GetItemCode(Eval("CallStatus")) %>
                            </td>
                            
                            </tr>
                            <tr>
                            <td colspan="3">
                            <hr />
                            </td>
                            </tr>
                            <tr>
                            <td class="txtLabel">
                                Technician 
                            </td>
                            <td>
                               <%# GetEmployeeCode(Eval("TechID")) %>
                            </td>
                            
                            </tr>
                            <tr>
                            <td class="txtLabel">
                                Appointment 
                            </td>
                            <td>
                                <%# Eval("AppointmentDate", "{0:MMM dd, yyyy}") %>
                            </td>
                            
                            </tr>
                            <tr>
                            <td colspan="3">
                            <hr />
                            </td>
                            </tr>
                            <tr>
                            <td valign="top">
                                Call Note
                            </td>
                            <td colspan="2" >
                                <div style="height:35px;">
                                <%# Eval("CallNote") %>
                                </div>
                            </td>
                            <tr>
                            <td valign="top">
                                Repair Note
                            </td>
                            <td colspan="2">
                                <div style="height:35px;">
                                <%# Eval("RepairNote") %>
                                </div>
                            </td>
                            
                        </tr>
                        
                             </table>
                    
                   </EditForm>
             
            </Templates>
        </dxwgv:ASPxGridView>

      
         
    </div>
    </form>
</body>
</html>
